package TAIC.feature;

import java.io.File;
import java.io.PrintStream;
import java.util.Scanner;

public class MatForOneClass {

		public static void main ( String args []  ) throws Exception {
			if ( args.length != 1 ) {
				System.out.println ( "Please input the fold name" ) ;
				return ; 
			}
			( new MatForOneClass()).work ( args ) ; 
		}
		
		public void work ( String args [ ]  ) throws Exception {
			int totalLines = 0 ; 
			Scanner scanner = new Scanner ( new File ( args [ 0 ]	 + "\\index.txt")) ; 
			while ( scanner.hasNextLine() ) {
				String fileName = scanner.nextLine().trim(); 
				Scanner fileScanner = new Scanner ( new File ( args [ 0 ] + "\\" + fileName + ".sift_o")) ;
				totalLines += fileScanner.nextInt() ;
				fileScanner.close() ; 
			}
			scanner.close() ; 

			scanner = new Scanner ( new File ( args [ 0 ] + "\\index.txt"));
			PrintStream fout = new PrintStream ( new File ( args[ 0 ] + "\\mat" )) ;			

			fout.println ( totalLines + " " + 128 ) ; 
			while ( scanner.hasNextLine() ) {
				String fileName = scanner.nextLine().trim(); 
				Scanner fileScanner = new Scanner ( new File ( args [ 0 ] + "\\" + fileName + ".sift_o")) ;
				int lines = fileScanner.nextInt() ;
				fileScanner.nextInt() ; 
				for ( int i = 0 ; i < lines ; i ++ ) {
					for ( int j = 0 ; j < 4 ; j ++ ) fileScanner.nextDouble() ;
					fout.println ( fileScanner.nextLine() ) ;
				}
				fileScanner.close() ; 
			}
			scanner.close();
			fout.close() ;
		}
}
